//
//  NSArray+JSON.m
//  meets-ios
//
//  Created by Mark on 15/12/11.
//  Copyright © 2015年 meets. All rights reserved.
//

#import "NSArray+JSON.h"

@implementation NSArray (JSON)

- (NSString *)convertJSONStringWithPrettyPrint:(BOOL)prettyPrint {
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
                                                       options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
                                                         error:&error];
    
    if (!jsonData) {
        DDLogInfo(@"Convert JSONString error: %@", error.localizedDescription);
        return @"{}";
    } else {
        return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
}

@end
